<?php
class Foxsis_Form_Dominio extends Zend_Form
{
    public function init()
    {
    	$view = $this->getView();
        $this->setAction($view->url(array('controller' => 'dominio', 'action' => 'save'), 'default', 'true'));
        
        $this->setMethod('POST');

        $this->setName("FormDominio");
		
        $id_dominio = new Zend_Form_Element_Hidden('id_dominio');
        $id_dominio->removeDecorator('HtmlTag')->removeDecorator('Label')
        		   ->addFilter('Int');
        
        $id_plano = new Zend_Form_Element_Hidden('id_plano');
        $id_plano->removeDecorator('HtmlTag')->removeDecorator('Label')
                 ->addFilter('Int');
        
        $id_cliente = new Zend_Form_Element_Hidden('id_cliente');
        $id_cliente->removeDecorator('HtmlTag')->removeDecorator('Label')
                   ->addFilter('Int');
        
        $id_usuario = new Zend_Form_Element_Hidden('id_usuario');
        $id_usuario->removeDecorator('HtmlTag')
                   ->removeDecorator('Label')
                   ->setValue(Zend_Auth::getInstance()->getIdentity()->id_usuario)
                   ->addFilter('Int');
                
        $url = new Zend_Form_Element_Text('url');
        $url->setLabel('URL:')
        		   ->setRequired(true)
                 ->addFilter('StripTags')
                 ->addFilter('StringTrim')
                 ->addValidator('NotEmpty')
                 ->setAttribs(
                 	array(
                 		"size" => "40",
                 		"maxlenght" => 100,
                 		"rel"	=> "Informe a URL."
                 	)
                 );
                 
    	$plano = new Plano();
        $result = $plano->fetchAll('ativo = 1');
               
        $id_plano = new Zend_Form_Element_Select('id_plano');
        $id_plano->setLabel('Plano:')
        		 ->setRequired(true)
                 ->addValidator('NotEmpty')
                 ->addMultiOption("", "-- Selecione --");
                 
    	foreach ($result as $plano) {
			$id_plano->addMultiOption($plano->id_plano, $plano->nome);
		}
		         
        $status = new Zend_Form_Element_Select('ativo');
        $status->setLabel('Status:')
        	   ->setRequired(true)
        	   ->setAttrib('rel', 'Informe o status do plano')
        	   ->addMultiOption("", "-- Selecione --")
        	   ->addMultiOption(1, "Ativo")
        	   ->addMultiOption(0, "Inativo");
        
        	   
        $this->addElements(
            array($id_dominio, $id_cliente, $id_usuario, $id_plano, $url, $plano, $status)
        );
        
        
    }
}